var httpRequestPool = new Array();

function createHttpRequest()
{
    var request=false;
    try
    {
        request=new ActiveXObject("Msxml2.XMLHTTP"); //IE新版本
    }
    catch (othermicrosoft)
    {
        try
        {
            request=new ActiveXObject("Microsoft.XMLHTTP"); //IE旧版本
        }
        catch (failed)
        {
            try
            {
                request=new XMLHttpRequest(); //mozilla
            }
            catch (trymicrosoft)
            {
                request=false;
            }
        }
    }

    if (!request) alert("Error initializing XMLHttpRequest!");

    return request;
}

function initPool()
{
    //alert("init pool!!!");
    var request=createHttpRequest();

    httpRequestPool[0]=request;
}

function getHttpRequest()
{
    if (httpRequestPool.length<1)
    {
        initPool()
    }

    //alert("getRequest!!!");
    var request=httpRequestPool[0];
    httpRequestPool.shift();
    return request;
}

function sendMsg(url,callBack,show)
{
    var request=getHttpRequest();
    if (request)
    {
        request.open("GET", url, true);
        request.onreadystatechange=function()
        {
          if(request.readyState == 4)
          {
             var ret="";
             if(request.status==200) {
            	 ret=request.responseText;
             }
             callBack(ret,show);
             httpRequestPool.push(request);
          }
        }
        request.send(null);
    }
}
